package com.abase.site.server;

import java.io.EOFException;
import java.io.File;
import java.io.FileReader;
import java.io.Reader;

import org.ho.yaml.YamlDecoder;

import com.abase.site.client.services.YAMLLoadingService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class YAMLLoadingServiceImpl extends RemoteServiceServlet implements YAMLLoadingService{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public String loadingYamlFileService(final String contenu) throws EOFException{
		YamlDecoder reader = null;
		try {
            Reader in = new FileReader(new File ("/contenu/" + contenu + ".yml"));
			reader = new YamlDecoder(in);
            in.close();

		} catch (Exception e) {
			e.printStackTrace();
		}
		Object object = reader.readObject();
		
		String texte = (String)object;
		System.out.println(texte);
		return texte;
	}

}
